<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="renderer" content="webkit">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=10, user-scalable=yes">
	<meta name="description" content="">
	<meta name="keywords" content="">
	<link rel="shortcut icon" href="./favicon.ico"/>
	<link rel="bookmark" href="./favicon.ico"/>
	<title>True Numbers Marker</title>
	
</head>
<body>
	
</body>
<script src="assets/js/lib/rule/full/ruleJS.all.full.js"></script>
<script src="assets/js/lib/handsontable/handsontable.full.js"></script>
<!-- <script src="assets/js/lib/echarts.min.js"></script> -->
<script src="assets/js/lib/jquery.js"></script>
<script src="assets/libs/bootstrap/js/bootstrap.min.js"></script>
<script src="../dist/app.min.js"></script>
<script>



// var admin=new ChartMarker(host);


var arr=[["地区","总量","总量排名"],["南京市","337.8","2"],["无锡市","274.9","3"],["徐州市","168.8","5"],["常州市","145.6","7"],["苏州市","545.4","1"],["南通市","189","4"],["连云港市","100.9","11"],["淮安市","120","8"],["盐城市","161.1","6"],["扬州市","107.1","9"],["镇江市","94.1","12"],["泰州市","104.1","10"],["宿迁市","83.7","13"]]

var _options=ChartParser.options();
var _group={"id":"7B0B576D-47D2-4B16-9FF6-E4A6B985649D","name":"g1","r":0,"c":0,"lr":13,"lc":6,"type":"bar","legend":[0,1,0,4],"category":[1,0,13,0],"value":[1,1,13,4]};

var cdata=parseData(arr,_group);
console.log(JSON.stringify(cdata));



// 处理图表数据
function parseData(data,group){
    var option=_options[group.type];
    var cdata={};
    option.base.forEach(function(e){
        if(!!group[e]){
            var d=getCells(data,group[e],e);
            cdata[e]={direction:d[0],value:d[1]};
        }
    }); 
    var parse=ChartParser[group.type];
    if(typeof parse==='function'){
        return parse(cdata);
    }
    return null;
}

function getCells(data,sels,type){
    var values=[];
    var direction='',ld=0,cd=0;
    var r=sels[0],c=sels[1],lr=sels[2],lc=sels[3];
    for(;r<=lr;r++){
        for(var _c=c;_c<=lc;_c++){
            var d=data[r][_c];
            if(d==null){
                if(type=='value'){
                    values.push({r:r,c:_c,value:null});
                }
            }else{
                values.push({r:r,c:_c,value:d});
            }
        }
    }
    if(lr-r<lc-c){
        direction='left-right';
    }else if(lr-r>lc-c){
        direction='top-bottom';
    }else{
        direction='';
    }
    return [direction, values];
}
</script>
</html>